package com.twq.basic

/**
 * Created by tangweiqun on 2017/11/18.
 */
object UsageScenario {
  def main(args: Array[String]): Unit = {
    //1、隐式视图(用于从一种类型到另一种类型的转换 -- 隐式转换)
    implicit def intToString(x: Int) = x.toString

    2.concat("test") //给已经存在的类型增加操作

    foo(2) //转变一个函数参数的类型

    //2、隐式参数(用于缺少参数方法的调用)
    implicit val test = 5
    findAnInt

  }

  def findAnInt(implicit x: Int) = x

  def foo(msg: String) = println(msg)
}
